<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	if($_RQ['jigouid']){
		$jigouid=$this->checklogin($_RQ['jigouid']);
	}elseif($_SESSION['jigouid']){
		$jigouid=$this->checklogin();
	}else{
		$jigouid=pdo_getcolumn('jy_chengedu_jigou',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'id');
		if(!$jigouid){
			exi('您还未注册机构','error',custom_url('jy_chengedu/register/',true));
			$info=pdo_get('core_members',array('id'=>$_SESSION['uid']),array('mobile','nickname','realname'));
			pdo_insert('jy_chengedu_jigou',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>1,'jointime'=>time(),'realname'=>$info['realname'],'mobile'=>$info['mobile'],'title'=>$info['nickname']));
			$jigouid=pdo_insertid();
		}
		$_SESSION['jigouid']=$_SESSION['jigouid']?:$jigouid;
	}
	$return['item']=pdo_get('jy_chengedu_jigou',array('id'=>$jigouid,'uniacid'=>$_SESSION['uniacid']));
	$return['plugin_icon']=$return['item']['logo'];
	$this->session('plugin_icon',$return['item']['logo']);
	$avatar=pdo_getcolumn('core_members',array('id'=>$return['item']['mid']),'avatar');
	$return['item']['logo']=$return['item']['logo']?$return['item']['logo']:$avatar;
	set_html('title','机构后台');
	exi($return);
}
if($_RQ['op']=='getlist'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid']);
    $orderby='id desc';
	$total='';
	$return['list']=pdo_getslice('jy_chengedu_school',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['status']=array('0'=>'不显示','1'=>'显示');
	exi($return);
}